package com.example.shop.service.impl;

import com.example.shop.entity.Reviews;
import com.example.shop.dao.ReviewsMapper;
import com.example.shop.service.ReviewsService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

import java.util.List;

/**
 * (Reviews)表服务实现类
 *
 * @author makejava
 * @since 2025-03-26 09:28:15
 */
@Service("reviewsService")
public class ReviewsServiceImpl implements ReviewsService {
    @Resource
    private ReviewsMapper reviewsMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param reviewid 主键
     * @return 实例对象
     */
    @Override
    public Reviews queryById(Integer reviewid) {
        return this.reviewsMapper.queryById(reviewid);
    }


    /**
     * 新增数据
     *
     * @param reviews 实例对象
     * @return 实例对象
     */
    @Override
    public Reviews insert(Reviews reviews) {
        this.reviewsMapper.insert(reviews);
        return reviews;
    }

    /**
     * 修改数据
     *
     * @param reviews 实例对象
     * @return 实例对象
     */
    @Override
    public Reviews update(Reviews reviews) {
        this.reviewsMapper.update(reviews);
        return this.queryById(reviews.getReviewid());
    }

    /**
     * 通过主键删除数据
     *
     * @param reviewid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer reviewid) {
        return this.reviewsMapper.deleteById(reviewid) > 0;
    }

    @Override
    public List<Reviews> queryAll() {
        return null;
    }
}
